#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
  pid_t id =fork();
  
  if(id==0)
  {
    //child
    while(1)
    {
     printf("我是子进程，我的pid：%d，我的父进程：%d\n",getpid(),getppid());  
    sleep(1);
    }
  }
  else
  {
  //parent 
  while(1)
  {
     printf("我是父进程，我的pid：%d，我的父进程：%d\n",getpid(),getppid());  
     sleep(1);
  }
  }

  return 0;
}


/*
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
int ret = fork();
if(ret < 0){
perror("fork");
return 1;
}
else if(ret == 0){ //child
printf("I am child : %d!, ret: %d\n", getpid(), ret);
}else{ //father
printf("I am father : %d!, ret: %d\n", getpid(), ret);
}
sleep(1);
return 0;
}*/
